package com.nbsaas.boot.ai.rest.resource;

import com.nbsaas.boot.ai.api.apis.AiSessionApi;
import com.nbsaas.boot.ai.data.entity.AiSession;
import com.nbsaas.boot.ai.api.domain.request.AiSessionRequest;
import com.nbsaas.boot.ai.api.domain.response.AiSessionResponse;
import com.nbsaas.boot.ai.api.domain.simple.AiSessionSimple;
import com.nbsaas.boot.ai.rest.convert.AiSessionSimpleConvert;
import com.nbsaas.boot.ai.rest.convert.AiSessionEntityConvert;
import com.nbsaas.boot.ai.rest.convert.AiSessionResponseConvert;
import com.nbsaas.boot.ai.data.repository.AiSessionRepository;

import java.io.Serializable;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;

/**
 * AI对话会话-业务接口实现
 */
@Transactional
@Service
public class AiSessionResource extends BaseResource<AiSession, AiSessionResponse, AiSessionSimple, AiSessionRequest> implements AiSessionApi {

    @Resource
    private AiSessionRepository aiSessionRepository;

    @Override
    public JpaRepositoryImplementation<AiSession, Serializable> getJpaRepository() {
        return aiSessionRepository;
    }

    @Override
    public Function<AiSession, AiSessionSimple> getConvertSimple() {
        return new AiSessionSimpleConvert();
    }

    @Override
    public Function<AiSessionRequest, AiSession> getConvertForm() {
        return new AiSessionEntityConvert();
    }

    @Override
    public Function<AiSession, AiSessionResponse> getConvertResponse() {
        return new AiSessionResponseConvert();
    }


}


